package com.spzx.product.controller;

import com.spzx.domain.Brand;
import com.spzx.product.mapper.BrandMapper;
import com.spzx.product.service.IBrandService;
import com.spzx.vo.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 品牌Controller
 */
@Tag(name = "品牌接口管理")
@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private IBrandService brandService;

    @Operation(summary = "查询品牌列表")
    @GetMapping("/list")
    public R list(Brand brand)
    {
        List<Brand> list = brandService.selectBrandList(brand);
        return R.ok(list);
    }

    @Operation(summary = "修改品牌")
    @PutMapping("update")
    public R update(@RequestBody Brand brand){
        //设置当前操作用户
        int rows = brandService.updateBrand(brand);
        return R.ok(rows);
    }

    //删除品牌
    @Operation(summary = "删除品牌")
    @DeleteMapping("remove/{ids}")
    public R remove(@PathVariable Long[] ids){
        return R.ok(brandService.deleteBrandByIds(ids));
    }

}
